function T = mult_helper(Z)
    height = size(Z,1);
    T = zeros(1,length(Z));
    for i = 1:height,
        T = T+Z(i,:);
        C = 1;
        while(sum(C)>0)
            C = T==2;
            C_LS = [C(2:end) 0];
            T(T==2) = 0;
            T = T + C_LS;
        end
    end
end